build: fix LLVM 18 build on GCC 15#4656
build: fix LLVM 18 build on GCC 15#4656XeniaLu wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
See also: referenced LLVM pull requests in patch files.
b248637 to
039dd17
Compare
|
Is this due to some compilation errors raised by GCC 15(or higher only)? Do lower versions of GCC, like GCC 11, encounter the same issues under specific conditions? |
|
It's only happening on GCC 15 (and higher, and potentially some corresponding versions of clang): llvm/llvm-project#101761 and llvm/llvm-project#123320 |
|
Will lower versions of GCC, like GCC 11 (default on Ubuntu 22.04), successfully compile LLVM libraries after applying those (llvm) patches? |
|
Yes, it builds on Ubuntu 22.04 (GCC 11) with the same patches. |
| print(f"cd {dst_dir} && {GIT_CLONE_CMD}") | ||
| subprocess.check_output(shlex.split(GIT_CLONE_CMD), cwd=dst_dir) | ||
|
|
||
| patch_dir = pathlib.Path(__file__).parent.joinpath("llvm-patches").resolve() |
There was a problem hiding this comment.
i suspect this should be target dependent.
while we are currently using the similar version (llvm-18) for all targets, it has not always been the case.
and it will unlikely be the case in future.
cf. #4654
lum1n0us
left a comment
There was a problem hiding this comment.
- The new patch files are organized as follows:
build-scripts/llvm-patches/
└── llvmorg-18.1.8/
├── 0001_Add_cstdint_to_SmallVector_101761.patch
└── 0002_Add_missing_include_to_X86MCTargetDesc.h_123320.patch
- The modification to build-scripts/build_llvm.py is:
--- a/build-scripts/build_llvm.py
+++ b/build-scripts/build_llvm.py
@@ -23,10 +23,17 @@
if not llvm_dir.exists():
GIT_CLONE_CMD = f"git clone --depth 1 --branch {llvm_branch} {llvm_repo} llvm"
print(GIT_CLONE_CMD)
subprocess.check_output(shlex.split(GIT_CLONE_CMD), cwd=dst_dir)
+ patch_dir = pathlib.Path(__file__).parent.joinpath(f"llvm-patches/{llvm_branch}").resolve()
+ if patch_dir.is_dir():
+ print(f"Applying patches from {patch_dir}")
+ for patch_file in sorted(patch_dir.glob("*.patch")):
+ cmd = f"git apply {patch_file}"
+ print(f"cd {llvm_dir} && {cmd}")
+ subprocess.check_output(shlex.split(cmd), cwd=llvm_dir)
+
return llvm_dir
See also: referenced LLVM pull requests in patch files.